<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <!-- BEGIN GLOBAL MANDATORY STYLES -->

    <!-- BEGIN GLOBAL MANDATORY STYLES -->
    <#include "../inc/list.ftl"/>
    <@list/>
</head>
<body >
<div class="panel panel-default">
    <div class="panel-body">
        <div class="row">
            <div class="col-lg-12">
                <form id="form" >
                    <div class="form-group" hidden >
                        <label>ID </label>
                        <input id="id"   name="id" value="${(brand.id)!}"  class="form-control" >
                    </div>
                    <div class="form-group">
                        <label>品牌名</label>
                        <input id="brandname"   name="brandname" value="${(brand.brandname)!}"  class="form-control">
                    </div>
                    <div align="right">
                        <button id="btn-submit"  type="button"  class="btn btn-default" >提交</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <!-- /.panel-body -->
</div>
<!-- /.panel -->
<script>
    $(document).ready(function() {
        $("#btn-submit").click(function(){
            var id = $.trim($("#id").val());
            var brandname = $.trim($("#brandname").val());
            if(brandname == ""){
                layer.msg('请输入品牌名!', {time: 1000});
                return false;
            }else {
                var data1= {};
                data1.id = id;
                data1.brandname = brandname;
                $.ajax({
                    type:"POST",
                    url:"/brand/update",  //接口
                    data:JSON.stringify(data1),
                    contentType: "application/json",
                    success:function(data){
                        if(data.result){
                            parent.layer.msg(data.msg, {time: 1000, icon:1});
                        }else{
                            parent.layer.msg(data.msg, {time: 1000, icon:2});
                        }
                        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                        parent.layer.close(index);
                    }
                });
            }
        });

    });
</script>
</body>

</html>